<?php 
namespace app\home\controller;
use think\Controller;
use think\Db;	
use think\Session;
use think\request;

class Huanx extends Controller{
	
	public function  huanx(){
				$data=$_POST;
				$str=json_encode($data);
				//file_put_contents('./ass01.txt',$str,FILE_APPEND);
				if($data['lcqjgj']=='anR5c2NteHdkeXQ='){
				$ste=Db::name('user_recharge')->where('tradeNo',$data['merBillNo'])->find();
				if($ste['paymentstate']==1)
				{
					return false;die;
				}
				if($ste)
				{
					     //修改充值表
					     Db::table('lc_user_recharge')->update(['id'=>$ste['id'],'paymentstate'=>1,'platformtradeNo'=>$data['ipsBillNo']]);
					     //资金日志表
					     $zprice=Db::name('cashlog')->where('uid',$ste['uid'])->order('id', 'desc')->limit(0,1)->find();
						 $balance=$zprice['balance']+$ste['amount'];
						 $list=['uid'=>$ste['uid'],'type'=>1,'price'=>$ste['amount'],'balance'=>$balance];
						 Db::table('lc_cashlog')->insert($list);
						  //存入用户余额
			             Db::table('lc_users')->where('id', $ste['uid'])->setInc('balance', $ste['amount']);
						 
				     }
					}
				  }
				}
?>